UEFI shell - 脚本文件

您所在的位置:网站首页 efi shell 退出 UEFI shell - 脚本文件

UEFI shell - 脚本文件

2024-07-14 16:56| 来源: 网络整理| 查看: 265

UEFI shell下的脚本文件的命名格式为: ****.nsh

脚本的语法和规范参考:

《EFI Shell User’s Guide》《UEFI原理与编程》 1. 写一个简单的脚本测试下:

脚本名为test.nsh,内容如下:

pci

在这里插入图片描述

2.开机自启动脚本

UEFI shell有一个开机自启动脚本,命名startup.nsh 在这里插入图片描述编辑下startup.nsh,内容为

date

开启虚拟机,不做任何操作,结果如下: 在这里插入图片描述

3.开机自启动脚本的代码实现

参考 edk2/ShellPkg/Application/Shell/Shell.c

... STATIC CONST CHAR16 mStartupScript[] = L"startup.nsh"; ... { ....... // // Try to find 'Startup.nsh' in the execution path defined by the environment variable PATH. // if ((StartupScriptPath == NULL) || EFI_ERROR (ShellIsFile (StartupScriptPath))) { SHELL_FREE_NON_NULL (StartupScriptPath); StartupScriptPath = ShellFindFilePath (mStartupScript); } ...... /** Find a file by searching the CWD and then the path. If FileName is NULL then ASSERT. If the return value is not NULL then the memory must be caller freed. @param FileName Filename string. @retval NULL the file was not found @return !NULL the full path to the file. **/ CHAR16 * EFIAPI ShellFindFilePath ( IN CONST CHAR16 *FileName ); };


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3